import { uniqueId } from "lodash";

export const supplementPath = menu => {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId("d2-menu-empty-"),
    ...(e.children
      ? {
          children: supplementPath(e.children)
        }
      : {})
  }));
};

export const firstUpperCase = ([first, ...rest]) => {
  return first.toUpperCase() + rest.join("");
};

//获取在框架内的路由
export const getFrameInRoutes = (routes, layout = "d2-layout-header-aside") => {
  return routes.filter(r => r.component.name === layout);
};
